home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume9 / uemacs3.8b / part03 < prev    next >
Encoding:
Internet Message Format  |  1987-05-04  |  47.2 KB

  1. Subject:  v09i035:  MicroEMACS, version 3.8b, Part03/14
  2. Path: mirror!sources-request
  3. From: sources-request@mirror.TMC.COM
  4. Newsgroups: comp.sources.unix
  5. Message-ID: <2286@mirror.TMC.COM>
  6. Sender: rs@mirror.TMC.COM
  7. Approved: rs@mirror.TMC.COM
  8. Lines: 1528
  9.  
  10. Submitted by: ihnp4!itivax!duncan!lawrence (Daniel Lawrence)
  11. Mod.sources: Volume 9, Issue 35
  12. Archive-name: uemacs3.8b/Part03
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line,
  16. # then unpack it by saving it in a file and typing "sh file".
  17. # If this archive is complete, you will see the message:
  18. #        "End of archive 3 (of 14)."
  19. # Contents:  edef.h emacs.hlp hp150.c input.c menu1
  20. # Wrapped by rs@mirror on Fri Mar 13 13:23:33 1987
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. echo shar: Extracting \"edef.h\" \(8520 characters\)
  23. if test -f edef.h ; then 
  24.   echo shar: Will not over-write existing file \"edef.h\"
  25. else
  26. sed "s/^X//" >edef.h <<'END_OF_edef.h'
  27. X/*    EDEF:        Global variable definitions for
  28. X            MicroEMACS 3.2
  29. X
  30. X            written by Dave G. Conroy
  31. X            modified by Steve Wilhite, George Jones
  32. X            greatly modified by Daniel Lawrence
  33. X*/
  34. X
  35. X/* some global fuction declarations */
  36. X
  37. Xchar *malloc();
  38. Xchar *strcpy();
  39. Xchar *strcat();
  40. Xchar *strncpy();
  41. Xchar *itoa();
  42. Xchar *getval();
  43. Xchar *gtenv();
  44. Xchar *gtusr();
  45. Xchar *gtfun();
  46. Xchar *token();
  47. Xchar *ltos();
  48. Xchar *flook();
  49. X
  50. X#ifdef    maindef
  51. X
  52. X/* for MAIN.C */
  53. X
  54. X/* initialized global definitions */
  55. X
  56. Xint     fillcol = 72;                   /* Current fill column          */
  57. Xshort   kbdm[NKBDM];            /* Macro                        */
  58. Xchar    pat[NPAT];                      /* Search pattern        */
  59. Xchar    rpat[NPAT];            /* replacement pattern        */
  60. Xchar    *execstr = NULL;        /* pointer to string to execute    */
  61. Xchar    golabel[NPAT] = "";        /* current line to go to    */
  62. Xint    execlevel = 0;            /* execution IF level        */
  63. Xint    eolexist = TRUE;        /* does clear to EOL exist    */
  64. Xint    revexist = FALSE;        /* does reverse video exist?    */
  65. Xint    flickcode = FALSE;        /* do flicker supression?    */
  66. Xchar    *modename[] = {            /* name of modes        */
  67. X    "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", "MAGIC", "CRYPT"};
  68. Xchar    modecode[] = "WCSEVOMY";    /* letters to represent modes    */
  69. Xint    gmode = 0;            /* global editor mode        */
  70. Xint    gfcolor = 7;            /* global forgrnd color (white)    */
  71. Xint    gbcolor    = 0;            /* global backgrnd color (black)*/
  72. Xint     sgarbf  = TRUE;                 /* TRUE if screen is garbage    */
  73. Xint     mpresf  = FALSE;                /* TRUE if message in last line */
  74. Xint    clexec    = FALSE;        /* command line execution flag    */
  75. Xint    mstore    = FALSE;        /* storing text to macro flag    */
  76. Xstruct    BUFFER *bstore = NULL;        /* buffer to store macro text to*/
  77. Xint     vtrow   = 0;                    /* Row location of SW cursor */
  78. Xint     vtcol   = 0;                    /* Column location of SW cursor */
  79. Xint     ttrow   = HUGE;                 /* Row location of HW cursor */
  80. Xint     ttcol   = HUGE;                 /* Column location of HW cursor */
  81. Xint    lbound    = 0;            /* leftmost column of current line
  82. X                       being displayed */
  83. Xint    taboff    = 0;            /* tab offset for display    */
  84. Xint    metac = CTRL | '[';        /* current meta character */
  85. Xint    ctlxc = CTRL | 'X';        /* current control X prefix char */
  86. Xint    reptc = CTRL | 'U';        /* current universal repeat char */
  87. Xint    abortc = CTRL | 'G';        /* current abort command char    */
  88. X
  89. Xint    quotec = 0x11;            /* quote char during mlreply() */
  90. Xchar    *cname[] = {            /* names of colors        */
  91. X    "BLACK", "RED", "GREEN", "YELLOW", "BLUE",
  92. X    "MAGENTA", "CYAN", "WHITE"};
  93. XKILL *kbufp  = NULL;        /* current kill buffer chunk pointer    */
  94. XKILL *kbufh  = NULL;        /* kill buffer header pointer        */
  95. Xint kused = KBLOCK;        /* # of bytes used in kill buffer    */
  96. XWINDOW *swindow = NULL;        /* saved window pointer            */
  97. Xint cryptflag = FALSE;        /* currently encrypting?        */
  98. Xshort    *kbdptr;        /* current position in keyboard buf */
  99. Xshort    *kbdend = &kbdm[0];    /* ptr to end of the keyboard */
  100. Xint    kbdmode = STOP;        /* current keyboard macro mode    */
  101. Xint    kbdrep = 0;        /* number of repetitions    */
  102. Xint    restflag = FALSE;    /* restricted use?        */
  103. Xlong    envram = 0l;    /* # of bytes current in use by malloc */
  104. Xint    macbug = FALSE;        /* macro debuging flag        */
  105. Xchar    errorm[] = "ERROR";    /* error literal        */
  106. Xchar    truem[] = "TRUE";    /* true literal            */
  107. Xchar    falsem[] = "FALSE";    /* false litereal        */
  108. Xint    cmdstatus = TRUE;    /* last command status        */
  109. X
  110. X/* uninitialized global definitions */
  111. X
  112. Xint     currow;                 /* Cursor row                   */
  113. Xint     curcol;                 /* Cursor column                */
  114. Xint     thisflag;               /* Flags, this command          */
  115. Xint     lastflag;               /* Flags, last command          */
  116. Xint     curgoal;                /* Goal for C-P, C-N            */
  117. XWINDOW  *curwp;                 /* Current window               */
  118. XBUFFER  *curbp;                 /* Current buffer               */
  119. XWINDOW  *wheadp;                /* Head of list of windows      */
  120. XBUFFER  *bheadp;                /* Head of list of buffers      */
  121. XBUFFER  *blistp;                /* Buffer for C-X C-B           */
  122. X
  123. XBUFFER  *bfind();               /* Lookup a buffer by name      */
  124. XWINDOW  *wpopup();              /* Pop up window creation       */
  125. XLINE    *lalloc();              /* Allocate a line              */
  126. Xchar    sres[NBUFN];        /* current screen resolution    */
  127. X
  128. X#else
  129. X
  130. X/* for all the other .C files */
  131. X
  132. X/* initialized global external declarations */
  133. X
  134. Xextern  int     fillcol;                /* Fill column                  */
  135. Xextern  short   kbdm[];                 /* Holds kayboard macro data    */
  136. Xextern  char    pat[];                  /* Search pattern               */
  137. Xextern    char    rpat[];            /* Replacement pattern        */
  138. Xextern    char    *execstr;        /* pointer to string to execute    */
  139. Xextern    char    golabel[];        /* current line to go to    */
  140. Xextern    int    execlevel;        /* execution IF level        */
  141. Xextern    int    eolexist;        /* does clear to EOL exist?    */
  142. Xextern    int    revexist;        /* does reverse video exist?    */
  143. Xextern    int    flickcode;        /* do flicker supression?    */
  144. Xextern    char *modename[];        /* text names of modes        */
  145. Xextern    char    modecode[];        /* letters to represent modes    */
  146. Xextern    KEYTAB keytab[];        /* key bind to functions table    */
  147. Xextern    NBIND names[];            /* name to function table    */
  148. Xextern    int    gmode;            /* global editor mode        */
  149. Xextern    int    gfcolor;        /* global forgrnd color (white)    */
  150. Xextern    int    gbcolor;        /* global backgrnd color (black)*/
  151. Xextern  int     sgarbf;                 /* State of screen unknown      */
  152. Xextern  int     mpresf;                 /* Stuff in message line        */
  153. Xextern    int    clexec;            /* command line execution flag    */
  154. Xextern    int    mstore;            /* storing text to macro flag    */
  155. Xextern    struct    BUFFER *bstore;        /* buffer to store macro text to*/
  156. Xextern    int     vtrow;                  /* Row location of SW cursor */
  157. Xextern    int     vtcol;                  /* Column location of SW cursor */
  158. Xextern    int     ttrow;                  /* Row location of HW cursor */
  159. Xextern    int     ttcol;                  /* Column location of HW cursor */
  160. Xextern    int    lbound;            /* leftmost column of current line
  161. X                       being displayed */
  162. Xextern    int    taboff;            /* tab offset for display    */
  163. Xextern    int    metac;            /* current meta character */
  164. Xextern    int    ctlxc;            /* current control X prefix char */
  165. Xextern    int    reptc;            /* current universal repeat char */
  166. Xextern    int    abortc;            /* current abort command char    */
  167. X
  168. Xextern    int    quotec;            /* quote char during mlreply() */
  169. Xextern    char    *cname[];        /* names of colors        */
  170. Xextern KILL *kbufp;            /* current kill buffer chunk pointer */
  171. Xextern KILL *kbufh;            /* kill buffer header pointer    */
  172. Xextern int kused;            /* # of bytes used in KB        */
  173. Xextern WINDOW *swindow;            /* saved window pointer        */
  174. Xextern int cryptflag;            /* currently encrypting?    */
  175. Xextern    short    *kbdptr;        /* current position in keyboard buf */
  176. Xextern    short    *kbdend;        /* ptr to end of the keyboard */
  177. Xextern    int kbdmode;            /* current keyboard macro mode    */
  178. Xextern    int kbdrep;            /* number of repetitions    */
  179. Xextern    int restflag;            /* restricted use?        */
  180. Xextern    long envram;        /* # of bytes current in use by malloc */
  181. Xextern    int    macbug;            /* macro debuging flag        */
  182. Xextern    char    errorm[];        /* error literal        */
  183. Xextern    char    truem[];        /* true literal            */
  184. Xextern    char    falsem[];        /* false litereal        */
  185. Xextern    int    cmdstatus;        /* last command status        */
  186. X
  187. X/* uninitialized global external declarations */
  188. X
  189. Xextern  int     currow;                 /* Cursor row                   */
  190. Xextern  int     curcol;                 /* Cursor column                */
  191. Xextern  int     thisflag;               /* Flags, this command          */
  192. Xextern  int     lastflag;               /* Flags, last command          */
  193. Xextern  int     curgoal;                /* Goal for C-P, C-N            */
  194. Xextern  WINDOW  *curwp;                 /* Current window               */
  195. Xextern  BUFFER  *curbp;                 /* Current buffer               */
  196. Xextern  WINDOW  *wheadp;                /* Head of list of windows      */
  197. Xextern  BUFFER  *bheadp;                /* Head of list of buffers      */
  198. Xextern  BUFFER  *blistp;                /* Buffer for C-X C-B           */
  199. X
  200. Xextern  BUFFER  *bfind();               /* Lookup a buffer by name      */
  201. Xextern  WINDOW  *wpopup();              /* Pop up window creation       */
  202. Xextern  LINE    *lalloc();              /* Allocate a line              */
  203. Xextern    char    sres[NBUFN];        /* current screen resolution    */
  204. X
  205. X#endif
  206. X
  207. X/* terminal table defined only in TERM.C */
  208. X
  209. X#ifndef    termdef
  210. Xextern  TERM    term;                   /* Terminal information.        */
  211. X#endif
  212. X
  213. X
  214. END_OF_edef.h
  215. if test 8520 -ne `wc -c <edef.h`; then
  216.     echo shar: \"edef.h\" unpacked with wrong size!
  217. fi
  218. # end of overwriting check
  219. fi
  220. echo shar: Extracting \"emacs.hlp\" \(8644 characters\)
  221. if test -f emacs.hlp ; then 
  222.   echo shar: Will not over-write existing file \"emacs.hlp\"
  223. else
  224. sed "s/^X//" >emacs.hlp <<'END_OF_emacs.hlp'
  225. X=>        MicroEMACS 3.8 Help screens        (01/18/87)
  226. X
  227. X    M-  means to use the <ESC> key prior to using another key
  228. X    ^A  means to use the control key at the same time as the A key
  229. X
  230. X^V or [Pg Dn]     Scroll down        M-< or <HOME>    Begining of file
  231. X^Z or [Pg Up]     Scroll up        M-> or <END>    End of file
  232. X
  233. X-----------------------------------------------------------------------
  234. X=>        (1) MOVING THE CURSOR
  235. X
  236. X^F  Forward character   M-F    Forward word        Keypad arrows
  237. X^B  Backward character  M-B    Backward word        are active!
  238. X^A  Front of line    M-G    Goto a line
  239. X^E  End of line        
  240. X^N  Next line        M-N    Front of paragraph
  241. X^P  Previous line    M-P    End of paragraph
  242. X-----------------------------------------------------------------------
  243. X=>        (2) DELETING & INSERTING
  244. X
  245. X<--             Delete previous character
  246. X^D or <DELETE>  Delete next character
  247. X^C or <INSERT>  Insert a space
  248. XM-<--           Delete previous word
  249. XM-D             Delete next word
  250. X^K              Close (delete) to end of line
  251. X-----------------------------------------------------------------------
  252. X=>        (2a) MORE DELETING & INSERTING
  253. X
  254. X<RETURN>   Insert a newline             <TAB>  Advance to next tab stop
  255. X^J         Insert a newline and indent  M-^W   Delete paragraph
  256. X^O         Open (insert) line
  257. X^W         Delete region between mark (set using M-<spacebar>) and cursor
  258. XM-W        Copy region to kill buffer
  259. X^X ^O      Delete blank lines around cursor
  260. X-----------------------------------------------------------------------
  261. X=>        (3) SEARCHING
  262. X
  263. X^S    Search forward from cursor position.
  264. X^R    Reverse search from cursor position.
  265. X^X S    Forward incremental search
  266. X^X R    Reverse incremental search
  267. X<ALT> S    Search for the next occurence of the last string (IBM-PC only)
  268. X<ALT> R    Search for the last occurence of the last string (IBM-PC only)
  269. X-----------------------------------------------------------------------
  270. X=>        (4) REPLACING
  271. X
  272. XM-R   Replace all instances of first typed-in string with second
  273. X          typed-in string.  End each string with ESC.
  274. XM-^R  Replace with query.  Answer with:
  275. X    ^G  cancel            .   exit to entry point
  276. X    !   replace the rest        Y    replace & continue
  277. X    ?   Get a list of options    N   no replacement & continue
  278. X-----------------------------------------------------------------------
  279. X=>        (5) CAPITALIZING & TRANSPOSING
  280. X
  281. XM-U    UPPERCASE word
  282. XM-C    Capitalize word        ^T    Transpose characters
  283. XM-L    lowercase word
  284. X^X ^L    lowercase region
  285. X^X ^U    uppercase region
  286. X^Q    Quote next entry, so that control codes may be entered into text
  287. X-----------------------------------------------------------------------
  288. X=>        (6) REGIONS & THE KILL BUFFER
  289. X
  290. XM-<spacebar>    set MARK at current position
  291. X^X ^X        eXchange mark and cursor
  292. X
  293. XA REGION will then be continuously-defined as the area between the mark and
  294. Xthe current cursor position.  The KILL BUFFER is the text which has been
  295. Xmost recently saved or deleted.
  296. X-----------------------------------------------------------------------
  297. X=>        (7) COPYING AND MOVING
  298. X
  299. X^W  Delete (Wipe) region        M-W    copy region to KILL buffer
  300. X^Y  Yankback save buffer at cursor
  301. XGenerally, the procedure for copying or moving text is:
  302. X    1)  Mark a REGION using M-<spacebar> at beginning and cursor at end.
  303. X    2)  Delete it (with ^W) or copy it (with M-W) into the KILL buffer.
  304. X    3)  Move the cursor to the desired location and yank it back (with ^Y).
  305. X-----------------------------------------------------------------------
  306. X=>        (8) MODES OF OPERATION
  307. X^X M    Add mode in buffer              M-M    Add global mode
  308. X^X ^M   Delete mode in buffer           M-^M   Delete global mode
  309. XOVER        Replaces (overwrites) rather than inserts characters
  310. XWRAP        Turns on word wrap (automatic carraige return).
  311. XVIEW        Allows viewing file without insertion and deletion.
  312. XCMODE        Automatic indenting for C program entry
  313. XEXACT/MAGIC    Changes how search and replace commands work (see next page)
  314. X-----------------------------------------------------------------------
  315. X=>        (9) SEARCH AND REPLACE MODES
  316. X
  317. XEXACT    Uppper/lower case is not ignored in searches
  318. XMAGIC   Regular pattern matching characters are active
  319. X    .   Matches any one character
  320. X    *   Matches any any number of the preceding character
  321. X    ^   Beginning of line        [ ]   Character class enclosure
  322. X    $   End of line              \     Quote next character
  323. X-----------------------------------------------------------------------
  324. X=>        (10) ON-SCREEN FORMATTING
  325. X
  326. X^X F        Set fill column
  327. XMn-<tab>    Set tab spacing to n charecters between tabs stops
  328. XM-Q        Format paragraph so that text lies between margins
  329. X^X =        Position report -- displays line number, char count,
  330. X                                   file size and character under cursor
  331. XM-^C        Count words/lines/chars in marked region
  332. X-----------------------------------------------------------------------
  333. X=>        (11) MULTIPLE WINDOWS
  334. X
  335. XMany WINDOWS may be active at once on the screen.  All windows may show
  336. Xdifferent parts of the same buffer, or each may display a different one.
  337. X^X 2    Split the current window in two    ^X O    Change to next window
  338. X^X 0    delete current window           ^X P    Change to previous window
  339. X^X 1    delete all other windows        M-^V    Page down next window
  340. X                                      M-^Z    Page up other window
  341. X-----------------------------------------------------------------------
  342. X=>        (12) CONTROLLING WINDOWS AND THE SCREEN
  343. X
  344. X^X ^    Enlarge current window   M-<n> ^X W   Resize window to <n> lines
  345. X^X ^Z   Shrink current window    M-<n> M-S    Change screen to <n> lines
  346. X^X ^N   Move window down         M-<n> M-T    Change screen to <n> columns
  347. X^X ^P   Move window up
  348. XM-^L    Reposition window
  349. X^L      Refresh the screen
  350. X-----------------------------------------------------------------------
  351. X=>        (13) MULTIPLE BUFFERS
  352. XA BUFFER is a named area containing a document being edited.  Many buffers
  353. Xmay be activated at once.
  354. X^X B    Switch to another buffer.  <CR> = use just-previous buffer
  355. X^X X    Switch to next buffer in buffer list
  356. XM-^N    Change name of current buffer
  357. X^X K    Delete a non-displayed buffer.
  358. X^X ^B    Display buffer directory in a window
  359. X-----------------------------------------------------------------------
  360. X=>        (14) READING FROM DISK
  361. X
  362. X^X ^F    Find file; read into a new buffer created from filename.
  363. X    (This is the usual way to begin editing a new file.)
  364. X^X ^R    Read file into current buffer, erasing its previous contents.
  365. X    No new buffer will be created.
  366. X^X ^I    Insert file into current buffer at cursor's location.
  367. X^X ^V    Find a file to make current in VIEW mode
  368. X-----------------------------------------------------------------------
  369. X=>        (15) SAVING TO DISK
  370. X
  371. X^X ^S    Save current buffer to disk
  372. X^X ^W    Write current buffer to disk
  373. X^X N    Change file name of current buffer
  374. XM-Z    Write out all changed buffers and exit MicroEMACS
  375. X
  376. X
  377. X-----------------------------------------------------------------------
  378. X=>        (16) ACCESSING THE OPERATING SYSTEM
  379. X
  380. X^X !    Send one command to the operating system and return
  381. X^X @    Pipe DOS command results to buffer
  382. X^X #    Filter buffer through DOS filter program
  383. X^X C    Start a new command processor under MicroEMACS
  384. X^X D    Suspend MicroEMACS into the background (UNIX BSD4.2 only)
  385. X^X ^C    Exit MicroEMACS
  386. X-----------------------------------------------------------------------
  387. X=>        (17) KEY BINDINGS AND COMMANDS
  388. X
  389. XM-K    Bind a key to a command        M-A  Describe a class of commands
  390. XM-^K    Unbind a key from a command
  391. X^X ?    Describe command bound to a key
  392. XM-X    Execute a named (and possibly unbound) command
  393. X{Describe-bindings}
  394. X    Display a list of all commands and key bindings to a buffer
  395. X-----------------------------------------------------------------------
  396. X=>        (18) COMMAND EXECUTION
  397. XCommands can be specified as command lines in the form:
  398. X    <optional repeat count> {command-name} <optional arguments>
  399. X{Execute-command-line}    execute a typed in command line
  400. X{Execute-buffer}    executes commands lines in a buffer
  401. X{Execute-file}        executes command lines from a file
  402. X{clear-message-line}    clears the message line during execution
  403. X   M-~            clears the change flag for a buffer
  404. X-----------------------------------------------------------------------
  405. X=>        (19) MACRO EXECUTION
  406. X
  407. X^X (    Start recording keyboard macro
  408. X^X )    Stop recording keyboard macro
  409. X^X E    Execute keyboard macro
  410. XM-<n> {store-macro}    Start recording named macro
  411. X      !endm        Stop recording named macro
  412. X{execute-macro-n}    Execute macro n (where n is from 1 to 20)
  413. X-----------------------------------------------------------------------
  414. X=>        (20) SPECIAL KEYS
  415. X
  416. X^G        Cancel current command and return to top level of processing.
  417. X^U or        Universal repeat.  May be followed by an integer (default = 4)
  418. XM-<digit>    and repeats the next command that many times.
  419. XM-X        Execute a named (and possibly unbound) command
  420. X
  421. X
  422. END_OF_emacs.hlp
  423. if test 8644 -ne `wc -c <emacs.hlp`; then
  424.     echo shar: \"emacs.hlp\" unpacked with wrong size!
  425. fi
  426. # end of overwriting check
  427. fi
  428. echo shar: Extracting \"hp150.c\" \(9129 characters\)
  429. if test -f hp150.c ; then 
  430.   echo shar: Will not over-write existing file \"hp150.c\"
  431. else
  432. sed "s/^X//" >hp150.c <<'END_OF_hp150.c'
  433. X/*
  434. X * The routines in this file provide support for HP150 screens
  435. X * and routines to access the Keyboard through KEYCODE mode.
  436. X * It compiles into nothing if not an HP150 screen device.
  437. X * added by Daniel Lawrence
  438. X */
  439. X
  440. X#define    termdef    1            /* don't define "term" external */
  441. X
  442. X#include        <stdio.h>
  443. X#include        "estruct.h"
  444. X#include    "edef.h"
  445. X
  446. X#if     HP150
  447. X
  448. X#define NROW    24                      /* Screen size.                 */
  449. X#define NCOL    80                      /* Edit if you want to.         */
  450. X#define    MARGIN    8            /* size of minimim margin and    */
  451. X#define    SCRSIZ    64            /* scroll size for extended lines */
  452. X#define    NPAUSE    15            /* # times thru update to pause */
  453. X#define BEL     0x07                    /* BEL character.               */
  454. X#define ESC     0x1B                    /* ESC character.               */
  455. X
  456. Xextern  int     openhp();               /* Forward references.          */
  457. Xextern  int     ttgetc();
  458. Xextern  int     ttputc();
  459. Xextern  int     ttflush();
  460. Xextern    int    hpflush();
  461. Xextern  int     closehp();
  462. Xextern    int    hp15kopen();
  463. Xextern    int    hp15kclose();
  464. Xextern  int     hp15move();
  465. Xextern  int     hp15eeol();
  466. Xextern  int     hp15eeop();
  467. Xextern  int     hp15beep();
  468. Xextern    int    gethpkey();
  469. Xextern    int    hp15rev();
  470. Xextern    int    hp15cres();
  471. X#if    COLOR
  472. Xextern    int    hp15fcol();
  473. Xextern    int    hp15bcol();
  474. X#endif
  475. X
  476. X/* weird to ascii translation table */
  477. X
  478. Xchar trans[][2] = {
  479. X    0x24,    9,    /* tab */
  480. X    0x25,    13,    /* ret */
  481. X    0x27,    8,    /* backspace */
  482. X    0x30,    48,    /* zero */
  483. X    0x31,    49,    /* one */
  484. X    0x32,    50,    /* two */
  485. X    0x33,    51,    /* three */
  486. X    0x34,    52,    /* four */
  487. X    0x35,    53,    /* five */
  488. X    0x36,    54,    /* six */
  489. X    0x37,    55,    /* seven */
  490. X    0x38,    56,    /* eight */
  491. X    0x39,    57,    /* nine */
  492. X    0x50,    13,    /* enter */
  493. X    0x54,    27,    /* break -> ESC */
  494. X    0x55,    27,    /* esc */
  495. X    0x58,    24,    /* stop -> ^X */
  496. X    0x70,    45,    /* N-minus */
  497. X    0x71,    42,    /* N-asterisk */
  498. X    0x72,    43,    /* N-plus */
  499. X    0x73,    47,    /* N-slash */
  500. X    0x74,    44,    /* N-comma */
  501. X    0x75,    13,    /* N-enter */
  502. X    0x76,    9,    /* N-tab */
  503. X    0x77,    46    /* N-period */
  504. X};
  505. X
  506. X#define NTRANS    sizeof(trans) / 2
  507. X
  508. Xunion REGS r;        /* register set for bios and dos (AGIOS) calls */
  509. Xint capslock = 0;    /* caps lock flag */
  510. X
  511. X/*
  512. X * Standard terminal interface dispatch table. Most of the fields point into
  513. X * "termio" code.
  514. X */
  515. XTERM    term    = {
  516. X    NROW-1,
  517. X        NROW-1,
  518. X        NCOL,
  519. X        NCOL,
  520. X    MARGIN,
  521. X    SCRSIZ,
  522. X    NPAUSE,
  523. X    openhp,
  524. X        closehp,
  525. X    hp15kopen,
  526. X    hp15kclose,
  527. X    gethpkey,
  528. X        ttputc,
  529. X        hpflush,
  530. X        hp15move,
  531. X        hp15eeol,
  532. X        hp15eeop,
  533. X        hp15beep,
  534. X        hp15rev,
  535. X        hp15cres
  536. X#if    COLOR
  537. X    , hp15fcol,
  538. X    hp15bcol
  539. X#endif
  540. X};
  541. X
  542. Xhp15move(row, col)
  543. X{
  544. X        ttputc(ESC);
  545. X        ttputc('&');
  546. X        ttputc('a');
  547. X        hp15parm(col);
  548. X        ttputc('c');
  549. X        hp15parm(row);
  550. X        ttputc('R');
  551. X}
  552. X
  553. Xhpflush()
  554. X
  555. X{
  556. X
  557. X}
  558. X
  559. Xhp15eeol()
  560. X{
  561. X        ttputc(ESC);
  562. X        ttputc('K');
  563. X}
  564. X
  565. Xhp15eeop()
  566. X{
  567. X        ttputc(ESC);
  568. X        ttputc('J');
  569. X}
  570. X
  571. Xhp15rev(status)        /* change the reverse video status */
  572. X
  573. Xint status;    /* TRUE = on, FALSE = off */
  574. X
  575. X{
  576. X    ttputc(ESC);
  577. X    ttputc('&');
  578. X    ttputc('d');
  579. X    ttputc((status != FALSE) ? 'B': '@');
  580. X}
  581. X
  582. Xhp15cres()    /* change screen resolution */
  583. X
  584. X{
  585. X    return(TRUE);
  586. X}
  587. X
  588. Xhp15beep()
  589. X{
  590. X        ttputc(BEL);
  591. X        ttflush();
  592. X}
  593. X
  594. Xhp15parm(n)
  595. Xregister int    n;
  596. X{
  597. X        register int    q;
  598. X
  599. X        q = n/10;
  600. X        if (q != 0)
  601. X                hp15parm(q);
  602. X        ttputc((n%10) + '0');
  603. X}
  604. X
  605. X#if    COLOR
  606. Xhp15fcol()    /* we really can't do colors here, so just ignore it */
  607. X{
  608. X}
  609. X
  610. Xhp15bcol()    /* we really can't do colors here, so just ignore it */
  611. X{
  612. X}
  613. X#endif
  614. X
  615. Xgethpkey()    /* get a key from the HP keyboard while in keycode mode */
  616. X
  617. X{
  618. X    static int keepflag = 0;    /* kept ahead char flag */
  619. X    static int keepchar = 0;    /* kept ehead flag */
  620. X    int c;
  621. X    int devid;            /* device ID */
  622. X    int ctype;            /* type of character gotten */
  623. X    int shiftb;            /* state of shift keys */
  624. X    int i;
  625. X    
  626. X    /* if we are in an extended char sequence, finish it */
  627. X    if (keepflag != 0) {
  628. X        keepflag = 0;
  629. X        return(keepchar);
  630. X    }
  631. X
  632. X    /* grab the next 4 char sequence */
  633. Xnext:    shiftb = ttgetc();
  634. X    devid = ttgetc();
  635. X    c = ttgetc();
  636. X    ttgetc();        /* skip null byte */
  637. X    
  638. X    /* make sure we are from the keyboard */
  639. X    if (devid != 192)
  640. X        goto next;
  641. X
  642. X    /* if normal ascii, return it */
  643. X    if ((shiftb & 0x80) == 0) {
  644. X        if (capslock && c >= 'a' && c <= 'z')
  645. X            c -= 32;
  646. X        return(c);
  647. X    }
  648. X
  649. X    /* check specifically for the caps lock key */
  650. X    if (c == 0x56) {
  651. X        capslock = ~capslock;
  652. X        goto next;
  653. X    }
  654. X
  655. X    /* check to see if it needs translation */
  656. X    for (i=0; i < NTRANS; i++)
  657. X        if (trans[i][0] == c)
  658. X            return((int)trans[i][1]);
  659. X
  660. X    /* other wise, shove it in the keep char and return the leadin code */
  661. X    keepchar = c;
  662. X    keepflag = 1;
  663. X    return(0);
  664. X}
  665. X
  666. Xopenhp()        /* open the HP150 screen for input */
  667. X
  668. X{
  669. X    strcpy(sres, "NORMAL");
  670. X    revexist = TRUE;
  671. X}
  672. X
  673. Xclosehp()        /* close the HP150 screen for input */
  674. X
  675. X{
  676. X}
  677. X
  678. Xhp15kopen()        /* open the HP150 keyboard for input */
  679. X
  680. X{
  681. X    /* define key charectoristics with AGIOS call (0, 40) */
  682. X    defkey();
  683. X
  684. X    /* Turn on RAW mode with MSDOS call 44h */
  685. X    rawon();
  686. X
  687. X    /* Turn off Control-C checking  MS-DOS 33h */
  688. X    ckeyoff();
  689. X
  690. X    /* Turn on keycode mode with AGIOS call (0,43) */
  691. X    keycon();
  692. X
  693. X    /* display the application softkey labels */
  694. X    dsplbls();
  695. X}
  696. X
  697. Xhp15kclose()        /* close the HP150 keyboard for input */
  698. X
  699. X{
  700. X    /* define key charectoristics with AGIOS call (0, 40) */
  701. X    undefkey();
  702. X    
  703. X    /* Turn off RAW mode with MSDOS call 44h */
  704. X    rawoff();
  705. X
  706. X    /* Turn on Control-C checking  MS-DOS 33h */
  707. X    ckeyon();
  708. X
  709. X    /* Turn off keycode mode with AGIOS call (0,43) */
  710. X    keycoff();
  711. X}
  712. X
  713. Xrawon()        /* put the HP150 keyboard into RAW mode */
  714. X
  715. X{
  716. X    /* get the IO control info */
  717. X
  718. X    r.x.ax = 0x4400;    /* IO ctrl get device information */
  719. X    r.x.bx = 0x0001;    /* File handle; 1 for console */
  720. X    intdos(&r, &r);        /* go fer it */
  721. X
  722. X    r.h.dh = 0;        /* clear high byte for put */
  723. X    r.h.dl |= 0x20;        /* set raw bit */
  724. X
  725. X    /* and put it back */
  726. X
  727. X    r.x.ax = 0x4401;    /* IO ctrl put device information */
  728. X    r.x.bx = 0x0001;    /* File handle; 1 for console */
  729. X    intdos(&r, &r);        /* go fer it */
  730. X}
  731. X
  732. Xrawoff()    /* put the HP150 keyboard into COOKED mode */
  733. X
  734. X{
  735. X    /* get the IO control info */
  736. X
  737. X    r.x.ax = 0x4400;    /* IO ctrl get device information */
  738. X    r.x.bx = 0x0001;    /* File handle; 1 for console */
  739. X    intdos(&r, &r);        /* go fer it */
  740. X
  741. X    r.h.dh = 0;        /* clear high byte for put */
  742. X    r.h.dl &= 0xdf;        /* set raw bit */
  743. X
  744. X    /* and put it back */
  745. X
  746. X    r.x.ax = 0x4401;    /* IO ctrl put device information */
  747. X    r.x.bx = 0x0001;    /* File handle; 1 for console */
  748. X    intdos(&r, &r);        /* go fer it */
  749. X}
  750. X
  751. X
  752. Xckeyoff()    /* turn control-C trapping off */
  753. X
  754. X{
  755. X    r.h.ah = 0x33;    /* ctrl-break check */
  756. X    r.h.al = 1;    /* set the state of the ctrl-break check */
  757. X    r.h.dl = 0;    /* turn it off */
  758. X    intdos(&r, &r);
  759. X}
  760. X
  761. Xckeyon()    /* turn control-C trapping on */
  762. X
  763. X{
  764. X    r.h.ah = 0x33;    /* ctrl-break check */
  765. X    r.h.al = 1;    /* set the state of the ctrl-break check */
  766. X    r.h.dl = 1;    /* turn it on */
  767. X    intdos(&r, &r);
  768. X}
  769. X
  770. Xagios(buf, len)    /* perform an AGIOS call */
  771. X
  772. Xchar *buf;    /* sequence of bytes in command */
  773. Xint len;    /* length of command in bytes */
  774. X
  775. X{
  776. X    r.x.ax = 0x4403;    /* I/O ctrl write */
  777. X    r.x.bx = 1;        /* console handle */
  778. X    r.x.cx = len;        /* buffer length */
  779. X    r.x.dx = (unsigned)buf;    /* buffer address */
  780. X    return(intdos(&r, &r));    /* do it */
  781. X}
  782. X
  783. Xkeycon()    /* turn keycode mode on */
  784. X
  785. X{
  786. X    static char cmd[] = {43, 0, 1};
  787. X
  788. X    return(agios(&cmd[0], 3));
  789. X}
  790. X
  791. Xkeycoff()    /* turn keycode mode off */
  792. X
  793. X{
  794. X    static char cmd[] = {43, 0, 0};
  795. X
  796. X    return(agios(&cmd[0], 3));
  797. X}
  798. X
  799. Xdefkey()    /* change all special keys to intercept mode */
  800. X
  801. X{
  802. X    static char cmd[] = {40, 0, 2, 0, 0xfe, 0};
  803. X
  804. X    return(agios(&cmd[0], 6));
  805. X}
  806. X
  807. Xundefkey()    /* change all special keys to intercept mode */
  808. X
  809. X{
  810. X    static char cmd[] = {40, 0, 0, 0, 0xfe, 0};
  811. X
  812. X    return(agios(&cmd[0], 6));
  813. X}
  814. X
  815. Xdsplbls()    /* display the application softkey labels on the screen */
  816. X
  817. X{
  818. X    static char cmd[] = {11, 0};
  819. X
  820. X    return(agios(&cmd[0], 2));
  821. X}
  822. X
  823. X#if    FLABEL
  824. Xfnclabel(f, n)        /* label a function key */
  825. X
  826. Xint f,n;    /* default flag, numeric argument */
  827. X
  828. X{
  829. X    register int status;    /* return status */
  830. X    register int i;        /* loop index */
  831. X    char lbl[17];    /* returned label contents */
  832. X    /* AGIOS command buffer */
  833. X    static char cmd[] = {8, 0, 1, 0, 7, 7, 7, 7, 10, 0, 10, 0};
  834. X    /*                   code  key#  ptr to      top    bottom
  835. X                                     label string  attribute */
  836. X    union {        /* union to cast ptr into AGIOS arg string */
  837. X        char *ptr;    /* pointer to arg string */
  838. X        char cstr[4];
  839. X    } ptru;
  840. X
  841. X    /* must have a numeric argument */
  842. X    if (f == FALSE) {
  843. X        mlwrite("%Need function key number");
  844. X        return(FALSE);
  845. X    }
  846. X
  847. X    /* and it must be a legal key number */
  848. X    if (n < 1 || n > 8) {
  849. X        mlwrite("%Function key number out of range");
  850. X        return(FALSE);
  851. X    }
  852. X
  853. X    /* get the string to send */
  854. X    status = mlreply("Label contents: ", &lbl[0], 17);
  855. X    if (status != TRUE)
  856. X        return(status);
  857. X
  858. X    /* pad the label out */
  859. X    for (i=0; i < 17; i++) {
  860. X        if (lbl[i] == 0)
  861. X            break;
  862. X    }
  863. X    for (; i < 16; i++)
  864. X        lbl[i] = ' ';
  865. X    lbl[16] = 0;
  866. X
  867. X    /* set up the parameters */
  868. X    cmd[2] = n;            /* function key number */
  869. X    ptru.ptr = &lbl[0];        /* set up pointer to label string */
  870. Xforce:    cmd[4] = ptru.cstr[0];
  871. X    cmd[5] = ptru.cstr[1];
  872. X    cmd[6] = ptru.cstr[2];
  873. X    cmd[7] = ptru.cstr[3];
  874. X
  875. X    /* and send it out */
  876. X    agios(&cmd[0], 12);
  877. X    return(TRUE);
  878. X}
  879. X#endif
  880. X#else
  881. X
  882. Xh15hello()
  883. X
  884. X{
  885. X}
  886. X#endif
  887. END_OF_hp150.c
  888. if test 9129 -ne `wc -c <hp150.c`; then
  889.     echo shar: \"hp150.c\" unpacked with wrong size!
  890. fi
  891. # end of overwriting check
  892. fi
  893. echo shar: Extracting \"input.c\" \(9854 characters\)
  894. if test -f input.c ; then 
  895.   echo shar: Will not over-write existing file \"input.c\"
  896. else
  897. sed "s/^X//" >input.c <<'END_OF_input.c'
  898. X/*    INPUT:    Various input routines for MicroEMACS 3.7
  899. X        written by Daniel Lawrence
  900. X        5/9/86                        */
  901. X
  902. X#include    <stdio.h>
  903. X#include    "estruct.h"
  904. X#include    "edef.h"
  905. X
  906. X#if    MEGAMAX
  907. Xoverlay "input"
  908. X#endif
  909. X
  910. X/*
  911. X * Ask a yes or no question in the message line. Return either TRUE, FALSE, or
  912. X * ABORT. The ABORT status is returned if the user bumps out of the question
  913. X * with a ^G. Used any time a confirmation is required.
  914. X */
  915. X
  916. Xmlyesno(prompt)
  917. X
  918. Xchar *prompt;
  919. X
  920. X{
  921. X    char c;            /* input character */
  922. X    char buf[NPAT];        /* prompt to user */
  923. X
  924. X    for (;;) {
  925. X        /* build and prompt the user */
  926. X        strcpy(buf, prompt);
  927. X        strcat(buf, " [y/n]? ");
  928. X        mlwrite(buf);
  929. X
  930. X        /* get the responce */
  931. X        c = tgetc();
  932. X
  933. X        if (c == ectoc(abortc))        /* Bail out! */
  934. X            return(ABORT);
  935. X
  936. X        if (c=='y' || c=='Y')
  937. X            return(TRUE);
  938. X
  939. X        if (c=='n' || c=='N')
  940. X            return(FALSE);
  941. X    }
  942. X}
  943. X
  944. X/*
  945. X * Write a prompt into the message line, then read back a response. Keep
  946. X * track of the physical position of the cursor. If we are in a keyboard
  947. X * macro throw the prompt away, and return the remembered response. This
  948. X * lets macros run at full speed. The reply is always terminated by a carriage
  949. X * return. Handle erase, kill, and abort keys.
  950. X */
  951. X
  952. Xmlreply(prompt, buf, nbuf)
  953. X    char *prompt;
  954. X    char *buf;
  955. X{
  956. X    return(nextarg(prompt, buf, nbuf, ctoec('\n')));
  957. X}
  958. X
  959. Xmlreplyt(prompt, buf, nbuf, eolchar)
  960. X
  961. Xchar *prompt;
  962. Xchar *buf;
  963. Xint eolchar;
  964. X
  965. X{
  966. X    return(nextarg(prompt, buf, nbuf, eolchar));
  967. X}
  968. X
  969. X/*    ectoc:    expanded character to character
  970. X        colapse the CTRL and SPEC flags back into an ascii code   */
  971. X
  972. Xectoc(c)
  973. X
  974. Xint c;
  975. X
  976. X{
  977. X    if (c & CTRL)
  978. X        c = c & ~(CTRL | 0x40);
  979. X    if (c & SPEC)
  980. X        c= c & 255;
  981. X    return(c);
  982. X}
  983. X
  984. X/*    ctoec:    character to extended character
  985. X        pull out the CTRL and SPEC prefixes (if possible)    */
  986. X
  987. Xctoec(c)
  988. X
  989. Xint c;
  990. X
  991. X{
  992. X        if (c>=0x00 && c<=0x1F)
  993. X                c = CTRL | (c+'@');
  994. X        return (c);
  995. X}
  996. X/* get a command name from the command line. Command completion means
  997. X   that pressing a <SPACE> will attempt to complete an unfinished command
  998. X   name if it is unique.
  999. X*/
  1000. X
  1001. Xint (*getname())()
  1002. X
  1003. X{
  1004. X    register int cpos;    /* current column on screen output */
  1005. X    register int c;
  1006. X    register char *sp;    /* pointer to string for output */
  1007. X    register NBIND *ffp;    /* first ptr to entry in name binding table */
  1008. X    register NBIND *cffp;    /* current ptr to entry in name binding table */
  1009. X    register NBIND *lffp;    /* last ptr to entry in name binding table */
  1010. X    char buf[NSTRING];    /* buffer to hold tentative command name */
  1011. X    int (*fncmatch())();
  1012. X
  1013. X    /* starting at the beginning of the string buffer */
  1014. X    cpos = 0;
  1015. X
  1016. X    /* if we are executing a command line get the next arg and match it */
  1017. X    if (clexec) {
  1018. X        if (macarg(buf) != TRUE)
  1019. X            return(FALSE);
  1020. X        return(fncmatch(&buf[0]));
  1021. X    }
  1022. X
  1023. X    /* build a name string from the keyboard */
  1024. X    while (TRUE) {
  1025. X        c = tgetc();
  1026. X
  1027. X        /* if we are at the end, just match it */
  1028. X        if (c == 0x0d) {
  1029. X            buf[cpos] = 0;
  1030. X
  1031. X            /* and match it off */
  1032. X            return(fncmatch(&buf[0]));
  1033. X
  1034. X        } else if (c == ectoc(abortc)) {    /* Bell, abort */
  1035. X            ctrlg(FALSE, 0);
  1036. X            TTflush();
  1037. X            return( (int (*)()) NULL);
  1038. X
  1039. X        } else if (c == 0x7F || c == 0x08) {    /* rubout/erase */
  1040. X            if (cpos != 0) {
  1041. X                TTputc('\b');
  1042. X                TTputc(' ');
  1043. X                TTputc('\b');
  1044. X                --ttcol;
  1045. X                --cpos;
  1046. X                TTflush();
  1047. X            }
  1048. X
  1049. X        } else if (c == 0x15) {    /* C-U, kill */
  1050. X            while (cpos != 0) {
  1051. X                TTputc('\b');
  1052. X                TTputc(' ');
  1053. X                TTputc('\b');
  1054. X                --cpos;
  1055. X                --ttcol;
  1056. X            }
  1057. X
  1058. X            TTflush();
  1059. X
  1060. X        } else if (c == ' ') {
  1061. X/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
  1062. X    /* attempt a completion */
  1063. X    buf[cpos] = 0;        /* terminate it for us */
  1064. X    ffp = &names[0];    /* scan for matches */
  1065. X    while (ffp->n_func != NULL) {
  1066. X        if (strncmp(buf, ffp->n_name, strlen(buf)) == 0) {
  1067. X            /* a possible match! More than one? */
  1068. X            if ((ffp + 1)->n_func == NULL ||
  1069. X               (strncmp(buf, (ffp+1)->n_name, strlen(buf)) != 0)) {
  1070. X                /* no...we match, print it */
  1071. X                sp = ffp->n_name + cpos;
  1072. X                while (*sp)
  1073. X                    TTputc(*sp++);
  1074. X                TTflush();
  1075. X                return(ffp->n_func);
  1076. X            } else {
  1077. X/* << << << << << << << << << << << << << << << << << */
  1078. X    /* try for a partial match against the list */
  1079. X
  1080. X    /* first scan down until we no longer match the current input */
  1081. X    lffp = (ffp + 1);
  1082. X    while ((lffp+1)->n_func != NULL) {
  1083. X        if (strncmp(buf, (lffp+1)->n_name, strlen(buf)) != 0)
  1084. X            break;
  1085. X        ++lffp;
  1086. X    }
  1087. X
  1088. X    /* and now, attempt to partial complete the string, char at a time */
  1089. X    while (TRUE) {
  1090. X        /* add the next char in */
  1091. X        buf[cpos] = ffp->n_name[cpos];
  1092. X
  1093. X        /* scan through the candidates */
  1094. X        cffp = ffp + 1;
  1095. X        while (cffp <= lffp) {
  1096. X            if (cffp->n_name[cpos] != buf[cpos])
  1097. X                goto onward;
  1098. X            ++cffp;
  1099. X        }
  1100. X
  1101. X        /* add the character */
  1102. X        TTputc(buf[cpos++]);
  1103. X    }
  1104. X/* << << << << << << << << << << << << << << << << << */
  1105. X            }
  1106. X        }
  1107. X        ++ffp;
  1108. X    }
  1109. X
  1110. X    /* no match.....beep and onward */
  1111. X    TTbeep();
  1112. Xonward:;
  1113. X    TTflush();
  1114. X/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
  1115. X        } else {
  1116. X            if (cpos < NSTRING-1 && c > ' ') {
  1117. X                buf[cpos++] = c;
  1118. X                TTputc(c);
  1119. X            }
  1120. X
  1121. X            ++ttcol;
  1122. X            TTflush();
  1123. X        }
  1124. X    }
  1125. X}
  1126. X
  1127. X/*    tgetc:    Get a key from the terminal driver, resolve any keyboard
  1128. X        macro action                    */
  1129. X
  1130. Xint tgetc()
  1131. X
  1132. X{
  1133. X    int c;    /* fetched character */
  1134. X
  1135. X    /* if we are playing a keyboard macro back, */
  1136. X    if (kbdmode == PLAY) {
  1137. X
  1138. X        /* if there is some left... */
  1139. X        if (kbdptr < kbdend)
  1140. X            return((int)*kbdptr++);
  1141. X
  1142. X        /* at the end of last repitition? */
  1143. X        if (--kbdrep < 1) {
  1144. X            kbdmode = STOP;
  1145. X#if    VISMAC == 0
  1146. X            /* force a screen update after all is done */
  1147. X            update(FALSE);
  1148. X#endif
  1149. X        } else {
  1150. X
  1151. X            /* reset the macro to the begining for the next rep */
  1152. X            kbdptr = &kbdm[0];
  1153. X            return((int)*kbdptr++);
  1154. X        }
  1155. X    }
  1156. X
  1157. X    /* fetch a character from the terminal driver */
  1158. X    c = TTgetc();
  1159. X
  1160. X    /* save it if we need to */
  1161. X    if (kbdmode == RECORD) {
  1162. X        *kbdptr++ = c;
  1163. X        kbdend = kbdptr;
  1164. X
  1165. X        /* don't overrun the buffer */
  1166. X        if (kbdptr == &kbdm[NKBDM - 1]) {
  1167. X            kbdmode = STOP;
  1168. X            TTbeep();
  1169. X        }
  1170. X    }
  1171. X
  1172. X    /* and finally give the char back */
  1173. X    return(c);
  1174. X}
  1175. X
  1176. X/*    GET1KEY:    Get one keystroke. The only prefixs legal here
  1177. X            are the SPEC and CTRL prefixes.
  1178. X                                */
  1179. X
  1180. Xget1key()
  1181. X
  1182. X{
  1183. X    int    c;
  1184. X#if    AMIGA
  1185. X    int    d;
  1186. X#endif
  1187. X
  1188. X    /* get a keystroke */
  1189. X        c = tgetc();
  1190. X
  1191. X#if    MSDOS
  1192. X    if (c == 0) {                /* Apply SPEC prefix    */
  1193. X            c = tgetc();
  1194. X            if (c>=0x00 && c<=0x1F)        /* control key? */
  1195. X                    c = CTRL | (c+'@');
  1196. X        return(SPEC | c);
  1197. X    }
  1198. X#endif
  1199. X
  1200. X#if    AMIGA
  1201. X    /* apply SPEC prefix */
  1202. X    if ((unsigned)c == 155) {
  1203. X        c = tgetc();
  1204. X
  1205. X        /* first try to see if it is a cursor key */
  1206. X        if ((c >= 'A' && c <= 'D') || c == 'S' || c == 'T')
  1207. X            return(SPEC | c);
  1208. X
  1209. X        /* next, a 2 char sequence */
  1210. X        d = tgetc();
  1211. X        if (d == '~')
  1212. X            return(SPEC | c);
  1213. X
  1214. X        /* decode a 3 char sequence */
  1215. X        c = d + 32;
  1216. X        /* if a shifted function key, eat the tilde */
  1217. X        if (d >= '0' && d <= '9')
  1218. X            d = tgetc();
  1219. X        return(SPEC | c);
  1220. X    }
  1221. X#endif
  1222. X
  1223. X#if  WANGPC
  1224. X    if (c == 0x1F) {            /* Apply SPEC prefix    */
  1225. X            c = tgetc();
  1226. X        return(SPEC | c);
  1227. X    }
  1228. X#endif
  1229. X
  1230. X        if (c>=0x00 && c<=0x1F)                 /* C0 control -> C-     */
  1231. X                c = CTRL | (c+'@');
  1232. X        return (c);
  1233. X}
  1234. X
  1235. X/*    GETCMD:    Get a command from the keyboard. Process all applicable
  1236. X        prefix keys
  1237. X                            */
  1238. Xgetcmd()
  1239. X
  1240. X{
  1241. X    int c;        /* fetched keystroke */
  1242. X
  1243. X    /* get initial character */
  1244. X    c = get1key();
  1245. X
  1246. X    /* process META prefix */
  1247. X    if (c == metac) {
  1248. X        c = get1key();
  1249. X            if (islower(c))        /* Force to upper */
  1250. X                    c ^= DIFCASE;
  1251. X            if (c>=0x00 && c<=0x1F)        /* control key */
  1252. X                c = CTRL | (c+'@');
  1253. X        return(META | c);
  1254. X    }
  1255. X
  1256. X    /* process CTLX prefix */
  1257. X    if (c == ctlxc) {
  1258. X        c = get1key();
  1259. X            if (c>='a' && c<='z')        /* Force to upper */
  1260. X                    c -= 0x20;
  1261. X            if (c>=0x00 && c<=0x1F)        /* control key */
  1262. X                c = CTRL | (c+'@');
  1263. X        return(CTLX | c);
  1264. X    }
  1265. X
  1266. X    /* otherwise, just return it */
  1267. X    return(c);
  1268. X}
  1269. X
  1270. X/*    A more generalized prompt/reply function allowing the caller
  1271. X    to specify the proper terminator. If the terminator is not
  1272. X    a return ('\n') it will echo as "<NL>"
  1273. X                            */
  1274. Xgetstring(prompt, buf, nbuf, eolchar)
  1275. X
  1276. Xchar *prompt;
  1277. Xchar *buf;
  1278. Xint eolchar;
  1279. X
  1280. X{
  1281. X    register int cpos;    /* current character position in string */
  1282. X    register int c;
  1283. X    register int quotef;    /* are we quoting the next char? */
  1284. X
  1285. X    cpos = 0;
  1286. X    quotef = FALSE;
  1287. X
  1288. X    /* prompt the user for the input string */
  1289. X    mlwrite(prompt);
  1290. X
  1291. X    for (;;) {
  1292. X        /* get a character from the user */
  1293. X        c = get1key();
  1294. X
  1295. X        /* If it is a <ret>, change it to a <NL> */
  1296. X        if (c == (CTRL | 0x4d))
  1297. X            c = CTRL | 0x40 | '\n';
  1298. X
  1299. X        /* if they hit the line terminate, wrap it up */
  1300. X        if (c == eolchar && quotef == FALSE) {
  1301. X            buf[cpos++] = 0;
  1302. X
  1303. X            /* clear the message line */
  1304. X            mlwrite("");
  1305. X            TTflush();
  1306. X
  1307. X            /* if we default the buffer, return FALSE */
  1308. X            if (buf[0] == 0)
  1309. X                return(FALSE);
  1310. X
  1311. X            return(TRUE);
  1312. X        }
  1313. X
  1314. X        /* change from command form back to character form */
  1315. X        c = ectoc(c);
  1316. X
  1317. X        if (c == ectoc(abortc) && quotef == FALSE) {
  1318. X            /* Abort the input? */
  1319. X            ctrlg(FALSE, 0);
  1320. X            TTflush();
  1321. X            return(ABORT);
  1322. X        } else if ((c==0x7F || c==0x08) && quotef==FALSE) {
  1323. X            /* rubout/erase */
  1324. X            if (cpos != 0) {
  1325. X                outstring("\b \b");
  1326. X                --ttcol;
  1327. X
  1328. X                if (buf[--cpos] < 0x20) {
  1329. X                    outstring("\b \b");
  1330. X                    --ttcol;
  1331. X                }
  1332. X
  1333. X                if (buf[cpos] == '\n') {
  1334. X                    outstring("\b\b  \b\b");
  1335. X                    ttcol -= 2;
  1336. X                }
  1337. X                TTflush();
  1338. X            }
  1339. X
  1340. X        } else if (c == 0x15 && quotef == FALSE) {
  1341. X            /* C-U, kill */
  1342. X            while (cpos != 0) {
  1343. X                outstring("\b \b");
  1344. X                --ttcol;
  1345. X
  1346. X                if (buf[--cpos] < 0x20) {
  1347. X                    outstring("\b \b");
  1348. X                    --ttcol;
  1349. X                }
  1350. X            }
  1351. X            TTflush();
  1352. X
  1353. X        } else if (c == quotec && quotef == FALSE) {
  1354. X            quotef = TRUE;
  1355. X        } else {
  1356. X            quotef = FALSE;
  1357. X            if (cpos < nbuf-1) {
  1358. X                buf[cpos++] = c;
  1359. X
  1360. X                if ((c < ' ') && (c != '\n')) {
  1361. X                    outstring("^");
  1362. X                    ++ttcol;
  1363. X                    c ^= 0x40;
  1364. X                }
  1365. X
  1366. X                if (c != '\n')
  1367. X                    TTputc(c);
  1368. X                else {    /* put out <NL> for <ret> */
  1369. X                    outstring("<NL>");
  1370. X                    ttcol += 3;
  1371. X                }
  1372. X                ++ttcol;
  1373. X                TTflush();
  1374. X            }
  1375. X        }
  1376. X    }
  1377. X}
  1378. X
  1379. Xoutstring(s)    /* output a string of characters */
  1380. X
  1381. Xchar *s;    /* string to output */
  1382. X
  1383. X{
  1384. X    while (*s)
  1385. X        TTputc(*s++);
  1386. X}
  1387. END_OF_input.c
  1388. if test 9854 -ne `wc -c <input.c`; then
  1389.     echo shar: \"input.c\" unpacked with wrong size!
  1390. fi
  1391. # end of overwriting check
  1392. fi
  1393. echo shar: Extracting \"menu1\" \(7926 characters\)
  1394. if test -f menu1 ; then 
  1395.   echo shar: Will not over-write existing file \"menu1\"
  1396. else
  1397. sed "s/^X//" >menu1 <<'END_OF_menu1'
  1398. X--<<01>>-----------------------------------------------------------------------
  1399. XMicroEMACS 3.7      F1 WORD CASE/SCREEN CONTROL   F2  PAGING/SCROLLING
  1400. X[Main Menu]         F3 CUT & PASTE                F4  SEARCH AND REPLACE
  1401. X                    F5 DELETION COMMANDS          F6  WORD PROCESSING
  1402. X                    F7 INSERTION COMMANDS         F8  EDITOR CONTROL
  1403. X 06/18/86           F9 CURSOR MOVEMENT            F10 exit MicroEMACS
  1404. X--<<02>>-----------------------------------------------------------------------
  1405. XMicroEMACS 3.7      F1 BUFFER CONTROL             F2  MACROS
  1406. X[Editor control]    F3 COLOR CHANGES              F4  MODES
  1407. X                    F5 DOS COMMANDS               F6  SCRIPTS
  1408. X                    F7 FILE ACCESS                F8  WINDOWS
  1409. X                    F9 KEY BINDINGS               F10 exit to MAIN MENU
  1410. X--<<03>>-----------------------------------------------------------------------
  1411. XMicroEMACS 3.7      F1 upper case a word          F2  upper case a region
  1412. X Word case &        F3 lower case a word          F4  lower case a region
  1413. X  Screen control    F5 capitilize a word
  1414. X                    F7 redraw the screen          F8  mark a region
  1415. X                    F9 center the current line    F10 exit to MAIN MENU
  1416. X--<<04>>-----------------------------------------------------------------------
  1417. XMicroEMACS 3.7      F1  mark a region
  1418. X  Cut & Paste       F3  delete the region
  1419. X                    F5  copy the region to the kill buffer
  1420. X                    F7  insert the kill buffer into the text here
  1421. X                                                  F10 exit to MAIN MENU
  1422. X--<<05>>-----------------------------------------------------------------------
  1423. XMicroEMACS 3.7      F1 delete the last character
  1424. X  Deletions         F3 delete the next character
  1425. X                    F5 delete to the end of the current line
  1426. X                    F7 delete all the blank lines around the cursor
  1427. X                                                  F10 exit to MAIN MENU
  1428. X--<<06>>-----------------------------------------------------------------------
  1429. XMicroEMACS 3.7      F1 open a blank line          F2  insert a prompted string
  1430. X  Insertion         F3 insert a tab               F4  quote the next character
  1431. X                    F5 insert a space             F6  transpose last 2 chars
  1432. X                    F7 insert a newline and indent like the last line
  1433. X                    F9 insert a newline           F10 exit to MAIN MENU
  1434. X--<<07>>-----------------------------------------------------------------------
  1435. XMicroEMACS 3.7      F1 begining of the file       F2  up one line
  1436. X  Cursor Movement   F3 left                       F4  right
  1437. X        F^2         F5 end of the file            F6  down one line
  1438. X    F3 < + > F4     F7 begining of line           F8  end of line
  1439. X        FV6         F9 goto line                  F10 exit to MAIN MENU
  1440. X--<<08>>-----------------------------------------------------------------------
  1441. XMicroEMACS 3.7      F1  go up one page            F2  go down one page
  1442. X  Paging and        F3  scroll the screen up      F4  scroll the screen down
  1443. X     Scrolling      F5  make the next widow go up one page
  1444. X                    F7  make the next window go down one page
  1445. X                    F9  exchange cursor & mark    F10 exit to MAIN MENU
  1446. X--<<09>>-----------------------------------------------------------------------
  1447. XMicroEMACS 3.7      f1  search forward            f2  seach backwards
  1448. X  Search and        F3  hunt forward              f4  hunt backwards
  1449. X    Replace         F5  isearch forward           F6  isearch backward
  1450. X                    F7  replace string            F8  replace string w/query
  1451. X                                                  F10 exit to MAIN MENU
  1452. X--<<10>>-----------------------------------------------------------------------
  1453. XMicroEMACS 3.7      F1 go back a word             F2  go forward a word
  1454. X  Word processing   F3 go back a paragraph        F4  go forward a paragraph
  1455. X                    F5 fill paragraph             F6  delete current paragraph
  1456. X                    F7 delete last word           F8  delete next word
  1457. X                    F9 count words in region      F10 exit to MAIN MENU
  1458. X--<<11>>-----------------------------------------------------------------------
  1459. XMicroEMACS 3.7      F1 report position            F2  unmark buffer
  1460. X  Buffer Control    F3 delete buffer              F4  switch to next buffer
  1461. X                    F5 list all buffers           F6  filter buffer through
  1462. X                    F7 rename current buffer             DOS program
  1463. X                    F9 select buffer              F10 exit to CONTROL MENU
  1464. X--<<12>>-----------------------------------------------------------------------
  1465. XMicroEMACS 3.7      Colors:           |  F1 current window's forground color
  1466. X  Color changes       Black   Magenta |  F3 current window's background color
  1467. X                      Blue    Cyan    |  F5 global forground color
  1468. X                      Red     Yellow  |  F7 global background color
  1469. X                      Green   White   |           F10  exit to CONTROL MENU
  1470. X--<<13>>-----------------------------------------------------------------------
  1471. XMicroEMACS 3.7      F1  execute one DOS command
  1472. X  DOS commands      F3  pipe one DOS command to a buffer
  1473. X                    F5  shell up to a new command interpeter
  1474. X                    F7  QUICK exit (write out all changed buffers and exit)
  1475. X                    F9  exit MicroEMACS           F10 exit to CONTROL MENU
  1476. X--<<14>>-----------------------------------------------------------------------
  1477. XMicroEMACS 3.7      F1 find file                  F2 save current file
  1478. X  File Access       F3 view file (in VIEW mode)   F4 write file w/ new name
  1479. X                    F5 read file into buffer      F6 change current file name
  1480. X                    F7 insert file into buffer
  1481. X                                                  F10  exit to CONTROL MENU
  1482. X--<<15>>-----------------------------------------------------------------------
  1483. XMicroEMACS 3.7      F1 bind a function to a key
  1484. X  Key Bindings      F3 unbind a key
  1485. X                    F5 describe a key
  1486. X                    F7 describe all bindings
  1487. X                                                  F10  exit to CONTROL MENU
  1488. X--<<16>>-----------------------------------------------------------------------
  1489. XMicroEMACS 3.7      F1 define macro         The keyboard macro only works
  1490. X  Keyboard Macro    F3 end macro            for standard commands, NOT for
  1491. X                    F5 execute macro        menu selections.
  1492. X
  1493. X                                                  F10  exit to CONTROL MENU
  1494. X--<<17>>-----------------------------------------------------------------------
  1495. XMicroEMACS 3.7      F1 set mode                   F2  set global mode
  1496. X  Modes             F3 delete mode                F4  delete global mode
  1497. X            Standard modes are:                   F6  set fill column
  1498. X                WRAP  VIEW  CMODE  EXACT OVER MAGIC
  1499. X                                                  F10 exit to CONTROL MENU
  1500. X--<<18>>-----------------------------------------------------------------------
  1501. XMicroEMACS 3.7      F1 execute script file        F2  execute script line
  1502. X  Script            F3 execute script in buffer   F4  execute command (by name)
  1503. X            Script line format:
  1504. X         {<repeat count>} <command name> {<argument(s)> | "<argument(s)>"}
  1505. X                                                  F10  exit to CONTROL MENU
  1506. X--<<19>>-----------------------------------------------------------------------
  1507. XMicroEMACS 3.7      F1 split current window       F2  delete all other windows
  1508. X  Windows           F3 resize window              F4  delete current window
  1509. X                    F5 shrink window              F6  enlarge window
  1510. X                    F7 next window                F8  previous window
  1511. X                                                  F10 exit to CONTROL MENU
  1512. X-------------------------------------------------------------------------------
  1513. END_OF_menu1
  1514. if test 7926 -ne `wc -c <menu1`; then
  1515.     echo shar: \"menu1\" unpacked with wrong size!
  1516. fi
  1517. # end of overwriting check
  1518. fi
  1519. echo shar: End of archive 3 \(of 14\).
  1520. cp /dev/null ark3isdone
  1521. MISSING=""
  1522. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  1523.     if test ! -f ark${I}isdone ; then
  1524.     MISSING="${MISSING} ${I}"
  1525.     fi
  1526. done
  1527. if test "${MISSING}" = "" ; then
  1528.     echo You have unpacked all 14 archives.
  1529.     echo "See the readme file"
  1530.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1531. else
  1532.     echo You still need to unpack the following archives:
  1533.     echo "        " ${MISSING}
  1534. fi
  1535. ##  End of shell archive.
  1536. exit 0
  1537.